package com.ruoyi.buss.utils;

import com.ruoyi.buss.system.domain.UserRole;
import com.ruoyi.system.api.model.LoginUser;

public class GetRoleUtil {

	public static UserRole GetRole(LoginUser userInfo) throws Exception {
		UserRole userRole = new UserRole();
		String orgId = userInfo.getSysUser().getDept().getOrgId();
		String orgName = userInfo.getSysUser().getDept().getDeptName();
		String userName = userInfo.getSysUser().getNickName();
		String userId = userInfo.getSysUser().getUserName();
		if (userInfo.getRoles().contains("admin") || userInfo.getRoles().contains("office")) {

		} else if (userInfo.getRoles().contains("zhhz")) {
			userRole.setOrgId(orgId);
			userRole.setOrgName(orgName);
		} else if (userInfo.getRoles().contains("common")) {
			userRole.setOrgId(orgId);
			userRole.setOrgName(orgName);
			userRole.setUserId(userId);
			userRole.setUserName(userName);
		} else {
			throw new Exception("没有权限进行该操作!");
		}
		return userRole;
	}
}
